<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<DiscMaster.Web.Models.Match>" %>
<%@ Register src="/Areas/Players/Views/Players/Details.ascx" tagname="Details" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	DiscMaster | Matches | <%= Model.name %> | Details
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <form id="form1" runat="server">

    <h1><%= Html.Encode(Model.name)%></h1> 
    at <%= Model.Course.name %>
    <br />created by <%= Html.ActionLink(Html.Encode(Model.Player.UserName),"Details", "Players", new {area="Players", id=Model.Player.UserId},null) %>
    <br />
    <h2>Details</h2>
    match with <%= Html.Encode(Model.MatchPlayers.Count) %> players played <%= Html.ActionLink(Html.Encode(String.Format("{0:d}", Model.matchdate)),"MatchesByDate","Index",null) %> at <%= Html.ActionLink(Model.Course.name,"Details", "Courses", new {area="Courses", id=Model.courseid},null) %> (<%= Html.ActionLink(Model.CourseLayout.name,"Layout", "Courses", new {area="Courses", id=Model.CourseLayout.layoutid},null) %>) with a par of <%= Html.Encode(Model.CourseLayout.Holes.Sum(h=>h.par)) %>.
    <h2>Players</h2>
    <% foreach (var item in Model.MatchPlayers) { %>
        <% Html.RenderPartial("~/Areas/Players/Views/Players/Details.ascx", item.Player); %>
    <% } %>
    <br style="clear: both;" />
    <%= Html.ActionLink("add new player", "AddPlayer", new { id = Model.matchid })%> | <%= Html.ActionLink("Remove a player", "RemovePlayer", new { id = Model.matchid })%>
    <h2>Results</h2>
    <% Html.RenderPartial("~/Areas/Matches/Views/Matches/Scorecard.ascx", Model); %>
    <%= Html.ActionLink("View detailed results..", "Results", new { id = Model.matchid }) %>
    <h2>Placings</h2>    
    <ol>
    <% foreach (var item in Model.MatchPlayers.OrderBy(mp=>mp.Scores.Sum(s=>s.result)))
       { %>
        <li><%= item.Player.UserName%> (<%= item.Scores.Sum(p => p.result)%>)
        </li>
    <% } %>
    </ol>
    <h2>Statistics</h2>
    <% Html.RenderPartial("~/Areas/Matches/Views/Matches/MatchResultsGraph.ascx", Model); %>
    <br />
    <%= Html.ActionLink("View detailed statistics..", "Statistics", new { id = Model.matchid }) %>
    <br />
    <%= Html.ActionLink("Edit this match", "Edit", new { id = Model.matchid })%>
    </form>

</asp:Content>

